package com.brtbeacon.demo.lot.state;

import android.os.Handler;

import com.brtbeacon.demo.lot.LotMapActivity;
import com.brtbeacon.demo.lot.fragment.ParkingTargetControlFragment;
import com.brtbeacon.locationengine.ble.BRTLocationManager;
import com.brtbeacon.map.map3d.BRTMapView;
import com.brtbeacon.map.map3d.entity.BRTPoi;
import com.brtbeacon.map.map3d.entity.BRTPoint;
import com.brtbeacon.mapdata.BRTLocalPoint;

import java.util.List;

/**
 * 编辑等待定位状态
 */

public class ParkingWaitLocationState extends ParkingState {

    private Handler handler = new Handler();

    @Override
    public void enter(LotMapActivity activity) {
        super.enter(activity);
        this.activity.setTopFragment(null);
        this.activity.setBottomFragment(null);
        this.activity.clearRouteResult();
        this.activity.getMapView().showRoutePassed(null);
        /*
        handler.postDelayed(new Runnable() {
            @Override
            public void run() {
                activity.showToast("未在停车场，无法进行车位导航操作！");
            }
        }, 15000);
         */

    }

    @Override
    public void exit() {
        if (this.activity != null) {
            this.activity.setTopFragment(null);
            this.activity.setBottomFragment(null);
        }
        super.exit();
        handler.removeCallbacksAndMessages(null);
    }

    @Override
    public void onClickAtPoint(BRTMapView mapView, BRTPoint point) {
        super.onClickAtPoint(mapView, point);
    }
    
    @Override
    public void onPoiSelected(BRTMapView brtMapView, List<BRTPoi> list) {
    }

    @Override
    public void didUpdateLocation(BRTLocationManager BRTLocationManager, BRTLocalPoint tyLocalPoint) {
        super.didUpdateLocation(BRTLocationManager, tyLocalPoint);
        //activity.setState(ParkingState.);
        if (activity.getParkingPoi() != null) {
            activity.setState(ParkingState.PARKING_STATE_NAVIGATION);
        } else {
            activity.setState(ParkingState.PARKING_STATE_TARGET);
        }
    }
}
